package com.promfy.anonymousshare;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;

import com.promfy.anonymousshare.domain.Login;
import com.promfy.anonymousshare.service.LoginManager;

/**
 * 程序启动界面
 * 
 * @author bob
 * 
 */
public class SplashActivity extends Activity {


	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);		

		setContentView(R.layout.activity_splash);
		new Handler().postDelayed(new Runnable() {
			@Override
			public void run() {
				LoginManager lm = new LoginManager(SplashActivity.this);
				Login login = lm.getLogin();
				if(login != null && login.isRememberPassword()){
					startMainActivity();
				}else{
					startLoginActivity();
				}
				
				finish();
			}

		}, 3000);
	}
	
	private void startLoginActivity() {
		Intent intent=new Intent(SplashActivity.this, LoginActivity.class);
		try{
		startActivity(intent);
		}catch(Exception e){
			e.printStackTrace();
		}
	}
	
	private void startMainActivity() {
		Intent intent=new Intent(SplashActivity.this, MainTabActivity.class);
		try{
		startActivity(intent);
		}catch(Exception e){
			e.printStackTrace();
		}
	}
	

}
